<template>
  <div class="table-page-search-wrapper" style="margin-top: 20px">
    <a-form-model
      :class="{ ischeck: disableSubmit }"
      :model="projectItem"
      :label-col="labelCol"
      :wrapper-col="wrapperCol"
    >
      <div class="table-page-search-wrapper" style="margin-top: 20px">
        <a-form-model :model="projectItem" :label-col="labelCol" :wrapper-col="wrapperCol">
          <!-- 资产负债率 -->
          <a-row>
            <a-form-model-item label="间接费用">
              <a-row :gutter="12">
                <a-col span="11" class="item_line">
                  <span>最低：</span>
                  <a-input
                    v-model="projectItem.jjfyStart"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'jjfyStart', 'start')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('jjfyStart')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('jjfyStart')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
                <a-col span="11" class="item_line">
                  <span>最高：</span>
                  <a-input
                    v-model="projectItem.jjfyEnd"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'jjfyEnd', 'end')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('jjfyEnd')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('jjfyEnd')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
              </a-row>
            </a-form-model-item>
          </a-row>
          <!-- 年应收客户合同工程款 -->
          <a-row>
            <a-form-model-item label="其它直接费用">
              <a-row :gutter="12">
                <a-col span="11" class="item_line">
                  <span>最低：</span>
                  <a-input
                    v-model="projectItem.qtzjfStart"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'qtzjfStart', 'start')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('qtzjfStart')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('qtzjfStart')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
                <a-col span="11" class="item_line">
                  <span>最高：</span>
                  <a-input
                    v-model="projectItem.qtzjfEnd"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'qtzjfEnd', 'end')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('qtzjfEnd')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('qtzjfEnd')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
              </a-row>
            </a-form-model-item>
          </a-row>
          <!-- 营业收入 -->
          <a-row>
            <a-form-model-item label="直接人工费">
              <a-row :gutter="12">
                <a-col span="11" class="item_line">
                  <span>最低：</span>
                  <a-input
                    v-model="projectItem.zjrgfStart"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'zjrgfStart', 'start')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('zjrgfStart')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('zjrgfStart')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
                <a-col span="11" class="item_line">
                  <span>最高：</span>
                  <a-input
                    v-model="projectItem.zjrgfEnd"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'zjrgfEnd', 'end')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('zjrgfEnd')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('zjrgfEnd')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
              </a-row>
            </a-form-model-item>
          </a-row>
          <!-- 年度经营性有息负债增 -->
          <a-row>
            <a-form-model-item label="机械使用费">
              <a-row :gutter="12">
                <a-col span="11" class="item_line">
                  <span>最低：</span>
                  <a-input
                    v-model="projectItem.jxsyfStart"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'jxsyfStart', 'start')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('jxsyfStart')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('jxsyfStart')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
                <a-col span="11" class="item_line">
                  <span>最高：</span>
                  <a-input
                    v-model="projectItem.jxsyfEnd"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'jxsyfEnd', 'end')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('jxsyfEnd')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('jxsyfEnd')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
              </a-row>
            </a-form-model-item>
          </a-row>
          <!-- 新签合同额增 -->
          <a-row>
            <a-form-model-item label="直接材料费">
              <a-row :gutter="12">
                <a-col span="11" class="item_line">
                  <span>最低：</span>
                  <a-input
                    v-model="projectItem.zjclfStart"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'zjclfStart', 'start')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('zjclfStart')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('zjclfStart')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
                <a-col span="11" class="item_line">
                  <span>最高：</span>
                  <a-input
                    v-model="projectItem.zjclfEnd"
                    class="addandsub_input"
                    @blur="handlerLimit($event, 'zjclfEnd', 'end')"
                  >
                    <a-button
                      slot="addonAfter"
                      class="btn_addandsub"
                      @click="addNumber('zjclfEnd')"
                      icon="plus"
                    ></a-button>
                    <a-button
                      slot="addonBefore"
                      class="btn_addandsub"
                      @click="subNumber('zjclfEnd')"
                      icon="minus"
                    ></a-button>
                  </a-input>
                </a-col>
              </a-row>
            </a-form-model-item>
          </a-row>
        </a-form-model>
      </div>
    </a-form-model>
  </div>
</template>

<script>
export default {
  name: 'AnalysisIndexcb',
  props: ['projectItem', 'disableSubmit'],
  data() {
    return {
      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
    }
  },
  methods: {
    addNumber(mysite) {
      this.$emit('addNumber', mysite,'cb')
    },
    subNumber(mysite) {
      this.$emit('subNumber', mysite,'cb')
    },
    handlerLimit(event, mysite, type) {
      let value = Number(event.target.value)
      console.log(value)
      if (type == 'start') {
        if (isNaN(value) || value > 1 || value < 0) {
          this.$emit('getValue', mysite, 0)
          return
        }
      } else if (type == 'end') {
        if (isNaN(value) || value > 1 || value < 0) {
          this.$emit('getValue', mysite, 1)
          return
        }
      }
      this.$emit('getValue', mysite, value)
    },
  },
}
</script>

<style lang="less" scoped>
.btn_position {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.item_line {
  display: flex;
  align-items: center;
}
.addandsub_input {
  width: 130px;
  /deep/ .ant-input-group-addon {
    padding: 0;
  }
  /deep/ .ant-input-group {
    width: 125px;
  }
  .btn_addandsub {
    height: 30px;
    width: 25px;
    padding: 0;
    border-color: #f9f9f9;
    background-color: #f9f9f9;
    .add {
    }
  }
}
.ischeck {
  /deep/.ant-input-disabled {
    color: black;
  }
}
</style>